
 


 
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <link rel="icon" type="image/vnd.microsoft.icon" href="http://www.gstatic.com/codesite/ph/images/phosting.ico">
 
 <script type="text/javascript">
 
 
 
 var codesite_token = "55b122417e72b952b1b3411d91b5d902";
 
 
 var logged_in_user_email = "efhennum@gmail.com";
 
 
 var relative_base_url = "";
 
 </script>
 
 
 <title>GettingStarted - 
 xspec -
 
 Getting Started with XSpec - Project Hosting on Google Code</title>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
 
 <meta name="ROBOTS" content="NOARCHIVE">
 
 <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/14756227129406843427/css/ph_core.css">
 
 <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/14756227129406843427/css/ph_detail.css" >
 
 
 
 <link type="application/atom+xml" rel="alternate" href="/feeds/p/xspec/svnchanges/basic?path=/wiki/GettingStarted.wiki">
 
 
<!--[if IE]>
 <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/14756227129406843427/css/d_ie.css" >
<![endif]-->
 <style type="text/css">
 .menuIcon.off { background: no-repeat url(http://www.gstatic.com/codesite/ph/images/dropdown_sprite.gif) 0 -42px }
 .menuIcon.on { background: no-repeat url(http://www.gstatic.com/codesite/ph/images/dropdown_sprite.gif) 0 -28px }
 .menuIcon.down { background: no-repeat url(http://www.gstatic.com/codesite/ph/images/dropdown_sprite.gif) 0 0; }
 </style>
</head>
<body class="t6">
 <script type="text/javascript">
 var _gaq = _gaq || [];
 _gaq.push(
 ['siteTracker._setAccount', 'UA-18071-1'],
 ['siteTracker._trackPageview']);
 
 _gaq.push(
 ['projectTracker._setAccount', 'UA-5548232-1'],
 ['projectTracker._trackPageview']);
 
 (function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
 })();
 </script>
 <div id="gaia">
 
 <span>
 
 
 <b>efhennum@gmail.com</b>
 
 
 | <a href="/u/efhennum/" id="projects-dropdown" onclick="return false;"
 ><u>My favorites</u> <small>&#9660;</small></a>
 | <a href="/u/efhennum/" onclick="_CS_click('/gb/ph/profile');" 
 title="Profile, Updates, and Settings"
 ><u>Profile</u></a>
 | <a href="https://www.google.com/accounts/Logout?continue=http%3A%2F%2Fcode.google.com%2Fp%2Fxspec%2Fwiki%2FGettingStarted" 
 onclick="_CS_click('/gb/ph/signout');"
 ><u>Sign out</u></a>
 
 </span>

 </div>
 <div class="gbh" style="left: 0pt;"></div>
 <div class="gbh" style="right: 0pt;"></div>
 
 
 <div style="height: 1px"></div>
<!--[if IE 6]>
<div style="text-align:center;">
Support browsers that contribute to open source, try <a href="http://www.firefox.com">Firefox</a> or <a href="http://www.google.com/chrome">Google Chrome</a>.
</div>
<![endif]-->




 <table style="padding:0px; margin: 20px 0px 0px 0px; width:100%" cellpadding="0" cellspacing="0">
 <tr style="height: 58px;">
 
 <td style="width: 55px; text-align:center;">
 <a href="/p/xspec/">
 
 <img src="http://www.gstatic.com/codesite/ph/images/defaultlogo.png" alt="Logo">
 
 </a>
 </td>
 
 <td style="padding-left: 0.5em">
 
 <div id="pname" style="margin: 0px 0px -3px 0px">
 <a href="/p/xspec/" style="text-decoration:none; color:#000">xspec</a>
 
 </div>
 <div id="psum">
 <i><a id="project_summary_link" href="/p/xspec/" style="text-decoration:none; color:#000">BDD framework for XSLT</a></i>
 </div>
 
 </td>
 <td style="white-space:nowrap;text-align:right">
 
 <form action="/hosting/search">
 <input size="30" name="q" value="">
 <input type="submit" name="projectsearch" value="Search projects" >
 </form>
 
 </tr>
 </table>


 
<table id="mt" cellspacing="0" cellpadding="0" width="100%" border="0">
 <tr>
 <th onclick="if (!cancelBubble) _go('/p/xspec/');">
 <div class="tab inactive">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner">
 <a onclick="cancelBubble=true;" href="/p/xspec/">Project&nbsp;Home</a>
 </div>
 </div>
 </th><td>&nbsp;&nbsp;</td>
 
 
 
 
 <th onclick="if (!cancelBubble) _go('/p/xspec/downloads/list');">
 <div class="tab inactive">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner">
 <a onclick="cancelBubble=true;" href="/p/xspec/downloads/list">Downloads</a>
 </div>
 </div>
 </th><td>&nbsp;&nbsp;</td>
 
 
 
 
 
 <th onclick="if (!cancelBubble) _go('/p/xspec/w/list');">
 <div class="tab active">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner">
 <a onclick="cancelBubble=true;" href="/p/xspec/w/list">Wiki</a>
 </div>
 </div>
 </th><td>&nbsp;&nbsp;</td>
 
 
 
 
 
 <th onclick="if (!cancelBubble) _go('/p/xspec/issues/list');">
 <div class="tab inactive">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner">
 <a onclick="cancelBubble=true;" href="/p/xspec/issues/list">Issues</a>
 </div>
 </div>
 </th><td>&nbsp;&nbsp;</td>
 
 
 
 
 
 <th onclick="if (!cancelBubble) _go('/p/xspec/source/checkout');">
 <div class="tab inactive">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner">
 <a onclick="cancelBubble=true;" href="/p/xspec/source/checkout">Source</a>
 </div>
 </div>
 </th><td>&nbsp;&nbsp;</td>
 
 
 <td width="100%">&nbsp;</td>
 </tr>
</table>
<table cellspacing="0" cellpadding="0" width="100%" align="center" border="0" class="st">
 <tr>
 
 
 
 <td>
 <div class="issueDetail">
<div class="isf">
 
 <span class="inIssueList"> 
 <span>Search</span>
 <form action="/p/xspec/w/list" method="GET" style="display:inline">
 <select id="can" name="can" style="font-size:92%">
 <option disabled="disabled">Search within:</option>
 
 <option value="1" >&nbsp;All wiki pages</option>
 <option value="3" >&nbsp;Featured pages</option>
 <option value="2" selected="selected">&nbsp;Current pages</option>
 
 
 <option value="5" {is can "5"}selected="selected"{end}>&nbsp;My starred pages</option>
 
 <option value="4" >&nbsp;Deprecated pages</option>
 
 </select>
 <span>for</span>
 <span id="qq"><input type="text" size="38" id="searchq" name="q" value=""
 autocomplete="off" style="font-size:92%" ></span>
 
 
 <input type="submit" value="Search" style="font-size:92%" >
 </form>
 </span>

 
 
 
 
 
 
 

</div>
</div>

 </td>
 
 
 
 
 
 
 <td height="4" align="right" valign="top" class="bevel-right">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 </td>
 </tr>
</table>
<script type="text/javascript">
 var cancelBubble = false;
 function _go(url) { document.location = url; }
</script>


<div id="maincol"
 
>

 
<!-- IE -->







 <style type="text/css">
 .artifactcomment {
 margin: .5em 0 0 0;
 padding: .3em 0 .3em .3em;
 border-top: 3px solid #c3d9ff;
 }
 #commentlist {
 border-bottom: 3px solid #c3d9ff;
 }
 #commentform { padding-top: 1em; }
 .delcom { background: #e8e8e8 }
 .commentcontent { margin: 1em 0;}
 </style>


 <div id="wikicontent">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
 
 <td class="vt" id="wikimaincol" width="100%">
 
 <div style="float:right; width:18em" id="wikimeta">
 <div class="pmeta_bubble_bg">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner">
 <table style="padding: 5px">
 <tr><td colspan="2" style="padding-bottom:5px">Updated <span title="Thu Mar 11 06:28:00 2010">Mar 11, 2010</span>
 
 by <a style="white-space: nowrap" href="/u/jsulak/">jsulak</a>
 </td></tr>
 
 <tr><th class="vt">Labels:</th>
 <td>
 
 <a href="/p/xspec/w/list?q=label:Phase-Deploy"
 title="How to install and configure the program"
 >Phase-Deploy</a>, 
 
 <a href="/p/xspec/w/list?q=label:Featured"
 title="Listed on project home page"
 >Featured</a>
 
 </td>
 </tr>
 
 
 </table>
 </div>
 <div class="round1"></div>
 <div class="round2"></div>
 <div class="round4"></div>
 </div>
 </div>
 
 <div id="wikiheader" style="margin-bottom:1em">
 
 <img width="15" height="15" id="star_img"
 src="http://www.gstatic.com/codesite/ph/images/star_off.gif"
 style="cursor:pointer"
 
 onclick="_CS_toggleStar(this,
 '',
 {'scope': 'wiki',
 'user': '_CURRENT_USER',
 'item': 'xspec:GettingStarted',
 'token': codesite_token
 });"/>
 
 &nbsp;
 <span style="font-size:120%;font-weight:bold">GettingStarted</span>
 &nbsp;
 
 
 <div style="font-style:italic; margin-top: 3px">Getting Started with XSpec</div>
 
 </div>
 <h1><a name="Contents"/>Contents<a href="#Contents" class="section_anchor">&para;</a></h1><p><ul><li><a href="#Contents">Contents</a></li><li><a href="#Introduction">Introduction</a></li><ul><li><a href="#Requirements">Requirements</a></li></ul><li><a href="#Installation">Installation</a></li><li><a href="#Your_First_Test_Suite">Your First Test Suite</a></li><li><a href="#Running_a_Test_Suite">Running a Test Suite</a></li><li><a href="#Working_With_XSpec_Documents">Working With XSpec Documents</a></li><li><a href="#Tips">Tips</a></li></ul> </p><h1><a name="Introduction"/>Introduction<a href="#Introduction" class="section_anchor">&para;</a></h1><p>This page demonstrates how to download, install, and use XSpec.  It also runs through testing an XSLT stylesheet.  The examples are in the <tt>tutorial</tt> directory of the XSpec download. </p><h2><a name="Requirements"/>Requirements<a href="#Requirements" class="section_anchor">&para;</a></h2><p>XSpec requires the Saxon XSLT and XQuery processors.  You probably already have them, but if you don&#x27;t, get them from <a href="http://saxon.sourceforge.net/" rel="nofollow">here</a>. </p><h1><a name="Installation"/>Installation<a href="#Installation" class="section_anchor">&para;</a></h1><p>To get started: </p><ol><li>Download the current version of XSpec from the <a href="http://code.google.com/p/xspec/downloads/list" rel="nofollow">download page</a>.  Unzip the archive somewhere accessible.  For this tutorial we&#x27;ll assume that XSpec is in <tt>c:\xspec\</tt> directory (Unix users can translate this.).   </li><li>Open xspec.bat in your favorite text editor.  Change the value on line 3 to the location of your saxon jar.  (Unix users can edit the same line of xspec.sh.) </li><li>Open up a command prompt.  Navigate to the XSpec executable directory, and test the batch script: </li></ol><blockquote><tt> &gt; xspec.bat </tt> 
</blockquote><p>You should get a usage summary: </p><pre class="prettyprint"> Usage:
   xspec filename [coverage]
     filename should specify an XSpec document
     if coverage is specified, outputs test coverage report</pre><h1><a name="Your_First_Test_Suite"/>Your First Test Suite<a href="#Your_First_Test_Suite" class="section_anchor">&para;</a></h1><p>Now that we have XSpec installed, we&#x27;re ready to try it out. XSpec comes with a sample of XSLT stylesheet to test and its sample test suite, both of which are in the <tt>tutorial</tt> directory. </p><p>If you want to have a look at them online, you can view them directly from the repository: <a href="http://code.google.com/p/xspec/source/browse/trunk/tutorial/escape-for-regex.xslt" rel="nofollow">the tested stylesheet</a> and <a href="http://code.google.com/p/xspec/source/browse/trunk/tutorial/escape-for-regex.xspec" rel="nofollow">the sample test suite</a>. </p><h1><a name="Running_a_Test_Suite"/>Running a Test Suite<a href="#Running_a_Test_Suite" class="section_anchor">&para;</a></h1><p>First, Copy the <tt>c:\xspec\tutorial</tt> subdirectory somewhere where you can work in it.  For the purposes of this tutorial, we&#x27;ll say it&#x27;s in <tt>c:\home\tutorial\</tt>.  Navigate to that directory and run the command: </p><pre class="prettyprint">&gt; c:\xspec\xspec.bat escape-for-regex.xspec</pre><p>If everything works correctly, an HTML report will appear in your browser.  The output in the shell should look like this: </p><pre class="prettyprint">C:\home\tutorial&gt;c:\xspec\xspec.bat escape-for-regex.xspec
Creating Test Stylesheet...
&quot;C:\home\tutorial\xspec\escape-for-regex.xsl&quot;
escape-for-regex.xspec

Running Tests...
Testing with SAXON 9.1.0.8
No escaping
Must not be escaped at all
Test simple patterns
..When encountering parentheses
escape them.
..When encountering a whitespace character class
escape the backslash
result should have one more character than source
When processing a list of phrases
All phrase elements should remain
String should be escaped and status attribute should be added
      FAILED

Formatting Report...
passed: 5 / pending: 0 / failed: 1 / total: 6
Done.</pre><p>And the HTML report should look like this:   </p><blockquote><a href="http://xspec.googlecode.com/svn/images/xsltreport.png" rel="nofollow"><img src="http://xspec.googlecode.com/svn/images/xsltreport-small.png" /></a> 
</blockquote><p>If you got an error, check to make sure that the path to the saxon jar is correct.  If you are still having issues, ask for help on the <a href="http://groups.google.com/group/xspec-users" rel="nofollow">XSpec mailing list</a>. </p><p>As you can see, one of the tests has failed.  We&#x27;ll come back to that.  For now, note that you invoke the XSpec script against the <i>test</i>, not the stylesheet.  The stylesheet filename is specified on the <tt>/x:description/@stylesheet</tt> attribute in the XSpec document. </p><p>If everything worked, there should be a new <tt>xspec</tt> subdirectory in <tt>c:\home\tutorial\</tt> (or your equivalent).  It contains three files generated by XSpec: </p><ul><li><strong><tt>escape-for-regex.xsl</tt></strong>  The XSpec test in XSLT form.   </li><li><strong><tt>escape-for-regex-result.xml</tt></strong>  The test results in XML format. </li><li><strong><tt>escape-for-regex.html</tt></strong>  The human-readable HTML test report.  Most of the time, this is the only file out of these three that you&#x27;ll care about. </li></ul><p>For more information about how the XSpec tests are run, see <a href="/p/xspec/wiki/RunningScenarios">RunningScenarios</a>.  </p><h1><a name="Working_With_XSpec_Documents"/>Working With XSpec Documents<a href="#Working_With_XSpec_Documents" class="section_anchor">&para;</a></h1><p>Open <a href="http://code.google.com/p/xspec/source/browse/trunk/tutorial/escape-for-regex.xslt" rel="nofollow">escape-for-regex.xslt</a> and <a href="http://code.google.com/p/xspec/source/browse/trunk/tutorial/escape-for-regex.xspec" rel="nofollow">escape-for-regex.xspec</a> in your favorite XML editor.  The transform has a single function and a couple of templates that we&#x27;re testing.   </p><p>The XSpec document has three top-level scenarios, which are contained in `&lt;x:scenario/&gt;&#x27;s.  The first two test the function, and the third tests the matching templates. </p><p>The first scenario is simple; it just calls the function <tt>functx:escape-for-regex()</tt> with the given parameter value and directly compares its result to our expected result.  A function is tested by using an <tt>&lt;x:call/&gt;</tt>, passing it a parameter using an <tt>&lt;x:param/&gt;</tt>.  Our expectations about how the functions should behave are captured by <tt>&lt;x:expect/&gt;</tt>s.  </p><p>Scenarios can be nested -- and the second top-level scenario is, containing two scenarios that test two aspects of the function <tt>functx:escape-for-regex()</tt>.  The first nested scenario is an equality test, just like the first-top level scenario.  The second nested scenario is more interesting -- it tests the output of a function against an XPath expression given in <tt>@test</tt>.  Note that we can have as many expectations as we like within a scenario. </p><p>The third top-level scenario tests the templates in the transform.  An <tt>&lt;x:context/&gt;</tt> contains a nodeset we want to apply templates to.  It has two expectations -- the first a simple XPath test, and the second demonstrates how we can directly compare a nodeset to the output by including the nodeset as descendants of an <tt>&lt;x:expect/&gt;</tt>. </p><p>Although it&#x27;s not shown here, both <tt>&lt;x:context/&gt;</tt> and <tt>&lt;x:call&gt;</tt> have optional <tt>@href</tt> and <tt>@select</tt> attributes, which can be a very powerful way to define tests.  <tt>@href</tt> is used to point to an external document, and <tt>@select</tt> is used to select certain nodes to test against.  </p><p>For a more detailed description of how a XSpec document is put together, see <a href="/p/xspec/wiki/WritingScenarios">WritingScenarios</a>. </p><p>One of the tests failed, so let&#x27;s fix it.  When a test fails in XSpec, the report shows both the actual result and the expected result side-by-side, with differences highlighted in red.  From this report, we can see that the failed scenario is labeled &quot;When processing a list of phrases&quot; and the specific expectation that failed is labeled &quot;Strings should be escaped and status attributes should be added.&quot;  The difference is that the <tt>@status</tt> attributes contain the wrong values.  Change line 35 of the transform to read: </p><pre class="prettyprint">   &lt;phrase status=&quot;{if (. = $escaped-text) then &#x27;same&#x27; else &#x27;changed&#x27;}&quot;&gt;</pre><p>Save the transform, and re-run the XSpec test.  All tests should be green: </p><blockquote><a href="http://xspec.googlecode.com/svn/images/xsltreport-pass.png" rel="nofollow"><img src="http://xspec.googlecode.com/svn/images/xsltreport-pass-small.png" /></a>  
</blockquote><h1><a name="Tips"/>Tips<a href="#Tips" class="section_anchor">&para;</a></h1><p>There are many ways to integrate XSpec into your workflow.  Here are a few tips: </p><ul><li>Add the XSpec executable directory to your system path. </li><li>By default, XSpec stores its result documents in the subdirectory &quot;xspec&quot; of the folder where the particular stylesheet that you are testing resides.  You may want to change the variable TEST_DIR to the system temporary folder: <tt>SET TEST_DIR=%TEMP%\xspec</tt>.  This works well when you are integrating the XSpec with Oxygen and don&#x27;t want to clutter up your project folders with XSpec results. </li><li><a href="http://www.wordsinboxes.com/2008/12/getting-started-with-xspec.html" rel="nofollow">Integrate XSpec into oXygen XML editor</a>. </li></ul>
 </td> 
 </tr>
 </table>
 </div>


 
 
 
 
 
 <div id="commentform">
 <form action="../w/detail.do" method="post">
 <table>
 <tr><td class="vt">
 <input type="hidden" name="pagename" value="GettingStarted" >
 <input type="hidden" name="token" value="55b122417e72b952b1b3411d91b5d902" >
 <div>Enter a comment:</div>
 <textarea name="content" rows="6" cols="80"></textarea><br><br>
 <input type="submit" name="submit" value="Submit" >
 </td>
 <td class="vt">
 <div id="whb" class="tip" style="width:15em">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner closed"
 id="entrybubble">
 <a class="ifClosed" href="#whb" style="float:right"
 onclick="_toggleHidden(this); document.getElementById('wikihelp').value='opened'">show</a>
 <a class="ifOpened" href="#whb" style="float:right"
 onclick="_toggleHidden(this); document.getElementById('wikihelp').value='closed'"
 >hide</a>
 <b>Wiki markup help</b>
 <div class="ifOpened">
 <div style="padding:2px; font-size:96%">
 =Heading1=<br>
 ==Heading2==<br>
 ===Heading3===<br>
 <br>
 *bold* &nbsp; &nbsp;
 _italic_<br>
 `inline code`<br>
 escape: `*`<br>
 <br>
 Indent lists 2 spaces:<br>
 &nbsp;&nbsp;* bullet item<br>
 &nbsp;&nbsp;# numbered list<br>
 <br>
 {{{<br>
 verbatim code block<br>
 }}}<br>
 <br>
 Horizontal rule<br>
 ----
 <br>
 <br>
 WikiWordLink<br>
 [http://domain/page&nbsp;label]<br>
 http://domain/page<br>
 <br>
 || table || cells ||<br>
 
 </div><br>
 <a href="http://code.google.com/p/support/wiki/WikiSyntax" target="new">More
 examples</a>
 <a href="http://code.google.com/p/support/wiki/WikiSyntax" target="new"><img
 src="http://www.gstatic.com/codesite/ph/images/tearoff_icon.gif" width="16" height="16"/></a>
 </div>
 </div>
 <div class="round1"></div>
 <div class="round2"></div>
 <div class="round4"></div>
</div>
<input type="hidden" name="wikihelp" id="wikihelp" value="closed" >

 </td></tr>
 </table>
 </form>
 </div>
 
 
 

<form name="delcom" action="../w/delComment.do" method="POST">
 <input type="hidden" name="sequence_num" value="" >
 <input type="hidden" name="create_time" value="" >
 <input type="hidden" name="mode" value="" >
 <input type="hidden" name="pagename" value="GettingStarted" >
 <input type="hidden" name="token" value="55b122417e72b952b1b3411d91b5d902" >
</form>



 <script src="http://www.gstatic.com/codesite/ph/14756227129406843427/js/prettify/prettify.js"></script>
 <script type="text/javascript">
 prettyPrint();
 </script>

<script type="text/javascript" src="http://www.gstatic.com/codesite/ph/14756227129406843427/js/dit_scripts.js"></script>



  
 
 <script type="text/javascript" src="http://www.gstatic.com/codesite/ph/14756227129406843427/js/core_scripts_20081103.js"></script>
 <script type="text/javascript" src="/js/codesite_product_dictionary_ph.pack.04102009.js"></script>
 </div>
<div id="footer" dir="ltr">
 
 <div class="text">
 
 &copy;2010 Google -
 <a href="/projecthosting/terms.html">Terms</a> -
 <a href="http://www.google.com/privacy.html">Privacy</a> -
 <a href="/p/support/">Project Hosting Help</a>
 
 </div>
</div>

 <div class="hostedBy" style="margin-top: -20px;">
 <span style="vertical-align: top;">Powered by <a href="http://code.google.com/projecthosting/">Google Project Hosting</a></span>
 </div>
 
 


 
 </body>
</html>


